var e = require("../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../@babel/runtime/regenerator")), t = require("../../../@babel/runtime/helpers/asyncToGenerator"), i = getApp();

Component({
    properties: {
        datas: {
            type: null
        },
        component_id: {
            type: null
        },
        page_id: {
            type: null
        }
    },
    data: {
        emptyImage: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/image.png",
        clientWidth: "375",
        showMargin: !0
    },
    observers: {
        datas: function(e) {
            this.setData({
                list: this.data.datas.list,
                clientWidth: wx.getSystemInfoSync().windowWidth
            });
        }
    },
    lifetimes: {
        attached: function() {
            var e = wx.getSystemInfoSync();
            if ("ios" == e.platform) {
                if ("iPhone 13 Pro Max<iPhone14,3>" == e.model) return void this.setData({
                    showMargin: !0
                });
                this.setData({
                    showMargin: !1
                });
            }
        },
        moved: function() {},
        detached: function() {}
    },
    attached: function() {},
    ready: function() {
        this.setData({
            list: this.data.datas.list,
            clientWidth: wx.getSystemInfoSync().windowWidth
        });
    },
    pageLifetimes: {
        show: function() {},
        hide: function() {},
        resize: function() {}
    },
    methods: {
        imgload: function(e) {
            this.triggerEvent("imgload", e);
        },
        toAreaUrl: function(e) {
            var t = e.currentTarget.dataset.item;
            if (2 != this.data.datas.choose_style) if (2 == t.is_minApp) if (t.gh_id) if (t.minApp_link) try {
                wx.navigateToMiniProgram({
                    appId: t.gh_id,
                    path: t.minApp_link,
                    extraData: {},
                    envVersion: "release",
                    success: function(e) {},
                    fail: function(e) {
                        wx.showToast({
                            title: "小程序跳转失败",
                            icon: "none",
                            duration: 2e3
                        });
                    }
                });
            } catch (e) {
                wx.showToast({
                    title: "小程序跳转失败",
                    icon: "none",
                    duration: 2e3
                });
            } else wx.showToast({
                title: "请设置跳转小程序后的跳转链接",
                icon: "none",
                duration: 2e3
            }); else wx.showToast({
                title: "请设置小程序所需跳转appId",
                icon: "none",
                duration: 2e3
            }); else {
                var i = t.h5_link, n = {
                    mid: wx.getStorageSync("yz_uid")
                };
                try {
                    i.indexOf("pages/live-player-plugin") > 0 && (i += "&open_share_ticket=1&custom_params=".concat(encodeURIComponent(JSON.stringify(n)))), 
                    wx.navigateTo({
                        url: i
                    });
                } catch (e) {
                    wx.showToast({
                        title: "链接设置错误",
                        icon: "none",
                        duration: 2e3
                    });
                }
            }
        },
        isMemberLevelUrl: function(e) {
            var t = this;
            return e.memberLevelOptions ? new Promise(function(n, a) {
                var r = i.getNetAddresss("plugin.decorate.frotend.basic-component.simplegraph");
                i._postNetWork({
                    url: r,
                    data: {
                        simplegraph_id: t.data.component_id,
                        decorate_id: t.data.page_id,
                        remote_data_list_id: e.id
                    },
                    success: function(t) {
                        var a = t.data;
                        if (1 !== a.result) return i.tips(a.msg), n(e);
                        n(a.data.jump_link);
                    },
                    fail: function(t) {
                        a(e);
                    }
                });
            }) : e;
        },
        goimgurl: function(n) {
            var a = this;
            return t(e.default.mark(function t() {
                var r, o, s, c, u;
                return e.default.wrap(function(e) {
                    for (;;) switch (e.prev = e.next) {
                      case 0:
                        return r = n.currentTarget.dataset.item, e.next = 3, a.isMemberLevelUrl(r);

                      case 3:
                        if (o = e.sent, 2 == a.data.datas.choose_style) {
                            e.next = 6;
                            break;
                        }
                        return e.abrupt("return");

                      case 6:
                        if (2 != o.is_minApp) {
                            e.next = 24;
                            break;
                        }
                        if (!o.gh_id) {
                            e.next = 18;
                            break;
                        }
                        if (!o.minApp_link) {
                            e.next = 12;
                            break;
                        }
                        try {
                            wx.navigateToMiniProgram({
                                appId: o.gh_id,
                                path: o.minApp_link,
                                extraData: {},
                                envVersion: "release",
                                success: function(e) {},
                                fail: function(e) {
                                    wx.showToast({
                                        title: "小程序跳转失败",
                                        icon: "none",
                                        duration: 2e3
                                    });
                                }
                            });
                        } catch (e) {
                            wx.showToast({
                                title: "小程序跳转失败",
                                icon: "none",
                                duration: 2e3
                            });
                        }
                        e.next = 16;
                        break;

                      case 12:
                        if (!i._isTextEmpty(o.minApp_link)) {
                            e.next = 15;
                            break;
                        }
                        return wx.previewImage({
                            current: o.image,
                            urls: [ o.image ]
                        }), e.abrupt("return");

                      case 15:
                        wx.showToast({
                            title: "请设置跳转小程序后的跳转链接",
                            icon: "none",
                            duration: 2e3
                        });

                      case 16:
                        e.next = 22;
                        break;

                      case 18:
                        if (!i._isTextEmpty(o.gh_id)) {
                            e.next = 21;
                            break;
                        }
                        return wx.previewImage({
                            current: o.image,
                            urls: [ o.image ]
                        }), e.abrupt("return");

                      case 21:
                        wx.showToast({
                            title: "请设置小程序所需跳转appId",
                            icon: "none",
                            duration: 2e3
                        });

                      case 22:
                        e.next = 31;
                        break;

                      case 24:
                        if (s = o.h5_link, c = wx.getStorageSync("yz_uid"), u = {
                            mid: c
                        }, !i._isTextEmpty(o.h5_link)) {
                            e.next = 30;
                            break;
                        }
                        return wx.previewImage({
                            current: o.image,
                            urls: [ o.image ]
                        }), e.abrupt("return");

                      case 30:
                        try {
                            s.indexOf("pages/live-player-plugin") > 0 && (s += "&open_share_ticket=1&custom_params=".concat(encodeURIComponent(JSON.stringify(u)))), 
                            wx.navigateTo({
                                url: s
                            });
                        } catch (e) {
                            wx.showToast({
                                title: "链接设置错误",
                                icon: "none",
                                duration: 2e3
                            });
                        }

                      case 31:
                      case "end":
                        return e.stop();
                    }
                }, t);
            }))();
        }
    }
});